package com.blackitheima3.polymorphic;

public class TestCatandA {
    public static void main(String[] args) {
        //多态 1.继承或者实现关系2.方法重写3.父类指向子类对象
        Animal a=new Cat();
        a.eat();

        //普通猫对象
        Cat c=new Cat();
        c.eat();

    }
}
//父类
abstract class Animal{
    public void eat(){
        System.out.println("动物吃饭!");
    }
}
//猫子类
class Cat extends Animal{
    @Override
    public void eat() {
        System.out.println("猫吃鱼!");
    }
}
